package com.ruan.lkx;

import com.alibaba.fastjson.JSONObject;
import com.ruan.lkx.address.Address;
import com.ruan.lkx.bean.HotVideo;
import com.ruan.lkx.bean.HotVideoCommon;
import com.ruan.lkx.net.HttpUtils;
import com.ruan.lkx.service.*;


import java.security.KeyPair;
import java.security.PrivateKey;
import java.util.List;
import java.util.Scanner;

/**
 * @author: likaixin
 * @emial: 2638784520@qq.com
 * @desc: 该类是java项目的主函数的类  是程序的入口
 * @datetime: 2021-12-05 21:33
 */
public class Main {
    public static void main(String[] args) {

//        HotVideoService hotVideoService = new HotVideoService();
//        List<HotVideo> hotVideo = hotVideoService.getHotVideo();
//        System.out.println(hotVideo.size());
////       System.out.println(hotVideoService.getHotVideo());

     run();
    }
    public static void run(){

        while (true){
            System.out.println("比特币系统设计系统");
            System.out.println("1.热门视频抓取\n2.和比特币客户端通信\n3.比特币地址推导 \n4.查看历史上的今天 \n5.查看生肖\n0.退出");
            userMenu();
        }
    }
    public static  void userMenu(){
        System.out.println("请输入要使用的功能序号:");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        switch (num){
            case 1://热门视频抓取
                HotVideoService hotVideo = new HotVideoService();
                List<HotVideo> videoList = hotVideo.getHotVideo();
                for(HotVideo video:videoList){
                    System.out.println(video.getShare_url());
                }
                break;
            case 2:
                GetBestBlockHash getBestBlockHash = new GetBestBlockHash();
                System.out.println(getBestBlockHash.getBestBlockHash().getResult());
                break;
            case 3:
                Address address = new Address();
                KeyPair keyPair = address.generateKeys();
                String s = address.newAddress(keyPair);
                System.out.println(s);
                boolean b = address.validateAddr(s);
                System.out.println(b);
                break;
            case 4:
                //获取历史上的今天
                HistoryServier historyServier = new HistoryServier();
                List<historyField> historyList = historyServier.getHistoryField();
                for (historyField historyField : historyList) {
                    System.out.println(historyField.getTitle());
                }
                break;
            case 5:
                //生肖查询
                AnimalService animalService = new AnimalService();

                System.out.println("请输入生肖");
                Scanner sc = new Scanner(System.in);
                String str = sc.next();
                List<Animal> animal = animalService.getAnimal(str);
                for (Animal animal1 : animal) {
                    System.out.println(animal1.aq);
                }
                break;
            case 0:
                System.out.println("欢迎下次光临");
                System.exit(0);
               break;

            default:
                System.out.println("输入有误,重新输入");
                break;
        }
    }
}
